<?php
include "ext/settings.php";
require('includes/application_top.php');

// Keep #'s reasonable.
$min_thickness = max(1,$min_thickness);
$max_thickness = min(20,$max_thickness);
// Make radii into height/width
$min_radius *= 2;
$max_radius *= 2;
// Renormalize contrast
$contrast = 255 * ($contrast / 100.0);
$o_contrast = 1.3 * $contrast;

$width = 85;
$height =20;
$image = imagecreatetruecolor ($width, $height);
imagealphablending($image, true);
$white = imagecolorallocate($image, 255 , 255, 255);
imagefill($image, 0, 0, $white);
//$black = imagecolorallocatealpha($image,255,255,50,127 );

// Build the  validation string
$max = strlen($acceptedChars)-1;
$password = NULL;
for($i=0; $i < $stringlength; $i++) {
	$cnum[$i] = $acceptedChars{mt_rand(0, $max)};
	$password .= $cnum[$i];
}

//Font
//echo '1';
$font = "ext/VeraSansBold.ttf";
//echo '2';die;
$font_size = 12;

for ($i = 0; $i < $stringlength; $i++) {
  $j=$i+1;
    $random_angle = mt_rand(-20 , 20);
	$red = mt_rand(0,255);
	$green = mt_rand(0,255);
	$blue = 255 - sqrt($red * $red + $green * $green);
	$color = imagecolorallocate ($image, 255, 100, 126);
   // if($i==0)
    //    imagettftext($image, $font_size, $random_angle, 10 , 20, $color, $font, $cnum[$i] );
   // else
        imagettftext($image, $font_size, $random_angle, $j * 12 , 15, $color, $font, $cnum[$i] );
}
//$session =& JFactory::getSession();
//$session->set("string",$password);
session_start();
$_SESSION['string_captcha'] = $password;
//echo $_SESSION['string_captcha'];
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>